package fr.upstlse.glre.client.secretaire;

import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FillLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;

import fr.upstlse.glre.client.administration.component.Center;
import fr.upstlse.glre.client.espacededie.AbstractEspaceDebie;
import fr.upstlse.glre.client.secretaire.component.EspaceSecretaireCenter;
import fr.upstlse.glre.client.secretaire.component.EspaceSecretaireHeader;
import fr.upstlse.glre.client.secretaire.component.EspaceSecretaireMenu;
import fr.upstlse.glre.client.utilitaires.ControlerUtil;
import fr.upstlse.glre.client.vo.user.UserVOGWT;

public class EspaceSecretaire extends AbstractEspaceDebie<UserVOGWT> {

	private static EspaceSecretaire instance;
	
	@Override
	public void getUserInformation(long pId) {
		ControlerUtil.getUserControlerServiceAsyncInstance().getUserById(pId,
				getUserInformationAsyncCallBack());
	}

	public static EspaceSecretaire getInstance() {
		if(instance == null) {
			instance = new EspaceSecretaire();
		}
		return instance;
	}

	@Override
	protected void createComponents() {
		viewport.setData("layout", new FitLayout());
		viewport.setLayout(new BorderLayout());
		viewport.setBorders(false);

		BorderLayoutData lHeaderLayoutData = new BorderLayoutData(
				LayoutRegion.NORTH, 80);
		BorderLayoutData lMenuLayoutData = new BorderLayoutData(
				LayoutRegion.WEST, 200, 150, 300);
		ContentPanel lMenuPanel = new ContentPanel();
		lMenuPanel.setLayout(new FillLayout());
		lMenuPanel.setHeading("Navigation");
		EspaceSecretaireMenu lMenu = new EspaceSecretaireMenu();
		lMenu.initWidget();
		lMenuPanel.add(lMenu);

		ContentPanel lCenterPanel = new ContentPanel();
		lCenterPanel.setLayout(new FillLayout());
		lCenterPanel.setHeaderVisible(false);
		EspaceSecretaireCenter lCenter = EspaceSecretaireCenter.getInstance();
		lCenter.initWidget();
		lCenterPanel.add(lCenter);
		
		EspaceSecretaireHeader lHeader = new EspaceSecretaireHeader();
		lHeader.initWidget();

		viewport.add(lHeader, lHeaderLayoutData);
		viewport.add(lMenuPanel, lMenuLayoutData);
		viewport.add(lCenterPanel, new BorderLayoutData(LayoutRegion.CENTER));
	}
	
	public static void killInstance() {
		Center.killInstance();
		instance = null;
	}

}
